var e = require("../../../@babel/runtime/helpers/interopRequireDefault").default, t = require("../../../@babel/runtime/helpers/regeneratorRuntime"), n = require("../../../@babel/runtime/helpers/asyncToGenerator"), a = e(require("../../../api/superMemberGold.js")), i = getApp();

Page({
    data: {
        showPage: !1,
        accountType: "领取账号",
        vipName: "",
        vipType: "",
        defaultRight: "",
        defaultRightAccount: ""
    },
    onLoad: function(e) {
        this.getUserInfo();
    },
    onReady: function() {},
    onShow: function() {},
    onHide: function() {},
    onUnload: function() {},
    onPullDownRefresh: function() {},
    onReachBottom: function() {},
    getUserInfo: function() {
        var e = this;
        return n(t().mark(function n() {
            var i, r, o, u, s, c, l, d, g;
            return t().wrap(function(t) {
                for (;;) switch (t.prev = t.next) {
                  case 0:
                    return wx.showLoading({
                        title: "加载中..."
                    }), t.prev = 1, t.next = 4, a.default.getUserInfo();

                  case 4:
                    return i = t.sent, r = i.data, o = r.defaultRight, u = r.defaultRightAccount, s = r.vipType, 
                    wx.hideLoading(), t.next = 12, e.getRightList(s);

                  case 12:
                    c = t.sent, l = "", d = "", g = !1, c.find(function(e) {
                        if (e.actionCode + "" == o + "") switch (l = e.accountName, !0) {
                          case "kuaishou" === e.type:
                          case e.name.includes("星巴克"):
                          case e.name.includes("美团外卖"):
                            d = e.name;
                            break;

                          case "100分钟全国语音" === e.name:
                            d = "当月" + e.name;
                            break;

                          default:
                            d = "1个月" + e.name;
                        } else if (e.innerRightList) {
                            var t = e.innerRightList.find(function(e) {
                                return e.actionCode + "" == o + "";
                            });
                            t && (l = t.accountName, d = t.name, g = !0);
                        }
                    }), e.setData({
                        showPage: !0,
                        accountType: l,
                        vipName: d,
                        showEduTips: g,
                        defaultRight: o,
                        defaultRightAccount: u
                    }), t.next = 24;
                    break;

                  case 20:
                    t.prev = 20, t.t0 = t.catch(1), wx.hideLoading(), wx.showModal({
                        title: "温馨提示",
                        content: t.t0.message || t.t0.msg || "请求失败，请稍后再试！",
                        showCancel: !1
                    });

                  case 24:
                  case "end":
                    return t.stop();
                }
            }, n, null, [ [ 1, 20 ] ]);
        }))();
    },
    getRightList: function(e) {
        return n(t().mark(function n() {
            var r, o;
            return t().wrap(function(t) {
                for (;;) switch (t.prev = t.next) {
                  case 0:
                    if (!i.globalData.rightList) {
                        t.next = 4;
                        break;
                    }
                    return t.abrupt("return", i.globalData.rightList);

                  case 4:
                    return t.prev = 4, t.next = 7, a.default.getRightList({
                        vipType: e
                    });

                  case 7:
                    return r = t.sent, o = r.data, t.abrupt("return", o);

                  case 12:
                    t.prev = 12, t.t0 = t.catch(4), wx.showModal({
                        title: "温馨提示",
                        content: t.t0.message || t.t0.msg || "请求失败，请稍后再试！",
                        showCancel: !1
                    });

                  case 15:
                  case "end":
                    return t.stop();
                }
            }, n, null, [ [ 4, 12 ] ]);
        }))();
    },
    gotoDetail: function() {
        wx.navigateTo({
            url: "/pages/superMemberGold/eduDetail/eduDetail?actionCode=" + this.data.defaultRight
        });
    },
    gotoMyRecord: function() {
        wx.navigateTo({
            url: "/pages/superMemberGold/webview/webview?type=sendRecord"
        });
    },
    gotoVip: function() {
        wx.navigateTo({
            url: "/pages/superMemberGold/webview/webview?type=vipCenter"
        });
    }
});